package com.yunji.cabinet.enums;

import com.yunji.common.utils.bean.BeanUtils;

import java.math.BigDecimal;

public enum VoltValueEnum {
    LEAST_VALUE(new BigDecimal("3.3"), "最小电量"),
    CRITICAL_VALUE(new BigDecimal("3.5"), "临界电量"),
    MAXIMUM_VALUE(new BigDecimal("4.1"),"最大电量");
    private final BigDecimal code;
    private final String text;

    VoltValueEnum(BigDecimal code, String text) {
        this.code = code;
        this.text = text;
    }

    public BigDecimal getCode() {
        return code;
    }

    public String getText() {
        return text;
    }

    public static String get(String code) {
        if (BeanUtils.isNull(code)) {
            return null;
        }
        VoltValueEnum[] enums = VoltValueEnum.values();
        for (VoltValueEnum e : enums) {
            if (e.code.equals(code)) {
                return e.text;
            }
        }
        return null;
    }
}
